﻿using log4net;
using SharpML.Api.Interfaces;
using SharpML.Api.Interfaces.Plugin;

namespace SharpML.Api.Abstraction.Plugin
{
    public abstract class MLTrainer : PluginComponent, IMLTrainer, IMLTrainerEvents, IHasSortPriority
    {
        #region - Private Member Variables -

            // Simple logging pattern
            private static readonly ILog Log = LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType );

            // Have each instance be uniquely identifiable
            private static long CurrentId = -1;

        #endregion
 
        #region - Public Events -

            public delegate void TrainerActivity( long id, IMLTrainer trainer );

            public event TrainerActivity OnTrainerStarted = delegate( long id, IMLTrainer trainer ) { };

        #endregion

        #region - Public Properties -

            /// <summary>
            /// The unique id for this instance
            /// </summary>
            public long Id = ++CurrentId;

            public IPatternDataAdaptor DataAdaptor { get; private set; }

        #endregion

        #region - Base Class Overrides -

            public override Enumerations.PluginComponentType Classification
            {
                get { return Enumerations.PluginComponentType.Trainer; }
            }

        #endregion

        #region - Abstract Implemenation -


        #endregion

        #region - Virtual IPluginTrainer Implemenation -

            /// <summary>
            /// Sets the data adaptor which the trainer will run
            /// </summary>
            /// <param name="dataAdaptor"></param>
            public virtual void Initialize( IPatternDataAdaptor dataAdaptor )
            {
                // Store data adaptor for later use
                DataAdaptor = dataAdaptor;
            }


        #endregion

        #region - Virtual IHasSortPriority Implemenation -

            public virtual int SortPriority { get { return 0; } }

        #endregion
    }
}
